package futures

class MutableStack<E>(vararg items: E) {

    private val elements = items.toMutableList()

    fun push(item: E) = elements.add(item)

    fun peek() = elements.last()

    fun pop(): E = elements.removeAt(elements.size - 1)

    fun isEmpty() = elements.isEmpty()

    fun size() = elements.size

    override fun toString(): String {
        return "MutableStack(${elements.joinToString(" - ")})"
    }

}

fun <E> mutableStackOf(vararg elements: E) = MutableStack<E>(*elements)

fun main() {
    val stack = mutableStackOf(0.62, 3.14, 2.7)
    println(stack)
}